package org.example.service;

import org.example.dao.UserDao;
import org.example.pojo.User;

public class UserService {
    private final UserDao userDao = new UserDao();

    // 验证用户登录
    public User validateUser(String username, String password) {
        return userDao.validateUser(username, password);
    }

    // 注册用户
    public boolean registerUser(String username, String password) {
        // 检查用户名是否存在
        if (userDao.isUsernameExists(username)) {
            return false; // 用户名已存在
        }
        return userDao.registerUser(username, password);
    }
}
